package com.codeos.httptest;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

public class MainEntry {


    public static void main(String[] args) throws Exception {
        URL url = new URL("http://rl.go2yd.com/pbonline/");
        HttpURLConnection httpClient = (HttpURLConnection) url.openConnection();
        httpClient.setRequestMethod("POST");

        httpClient.setRequestProperty("JSESSIONID","pBu63yn6qIT2_qaohuaP2Q");
        httpClient.setRequestProperty("Accept-Encoding", "gzip, deflate");
        httpClient.setRequestProperty("Content-Type", "application/x-www-form-urlencoded; charset=utf-8");
        httpClient.setRequestProperty("Host","rl.go2yd.com");
        httpClient.setRequestProperty("Connection","Keep-Alive");
        httpClient.setRequestProperty("User-Agent","Dalvik/2.1.0 (Linux; U; Android 8.1.0; OPPO R11t Build/OPM1.171019.011)");

        //设置连接超时
        httpClient.setConnectTimeout(8000);
        //设置读取超时的毫秒数
        httpClient.setReadTimeout(8000);
        //获取到服务器返回的输入流，字节输入流InputStream对象
        InputStream in = httpClient.getInputStream();
        //下面对获取到的输入流进行读取
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        StringBuilder response = new StringBuilder();
        String line;
        while((line = reader.readLine()) != null) {
            response.append(line);
        }
        System.out.println(response.toString());
    }
}
